#include "ClientConnectNetworkEvent.h"
#include <cstring>
#include "LobbyState.h"

ClientConnectNetworkEvent::ClientConnectNetworkEvent(const char* clientName)
{
    message.header.code = NetworkEvent::CLIENT_CONNECTED;
    message.header.sizeOfData = sizeof(message.data);
    strncpy(message.data.clientName, clientName, sizeof(message.data.clientName));
}

ClientConnectNetworkEvent::ClientConnectNetworkEvent(const Header& header, const Data& data)
{
    message.header = header;
    message.data = data;
}

ClientConnectNetworkEvent::~ClientConnectNetworkEvent()
{
}

void* ClientConnectNetworkEvent::getMessageBlob()
{
    return &message;
}

size_t ClientConnectNetworkEvent::getMessageBlobSize()
{
    return sizeof(message);
}

GameState* ClientConnectNetworkEvent::visitLobbyState(LobbyState* lobbyState) const
{
    return lobbyState->handleClientConnectEvent(message.header.playerId, message.data.clientName);
}
